{include file="public/toper" /}
<script type="text/javascript" src="/static/js/base64.js"></script>
<style>
    .layui-form-label{width:135px;}
    .layui-upload{width: 80% !important;}
    .layui-input-inline dt,dd{padding: 0px 25px !important;}
    /*.layui-form-select {width: 200px;}*/
    .goods_img {margin-left: 153px;}
</style>
<div class="x-body">
    <form action="" method="post" class="layui-form" id="forms">
        <input type="hidden" value="{$list.goods_id}" name="goods_id"/>
        <div class="layui-form-item">
            <label for="goods_name" class="layui-form-label">
                <span class="x-red">*</span>名称
            </label>
            <div class="layui-input-inline">
                <input type="text" id="goods_name" value="{$list.name}" name="name" required="" lay-verify="required" autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>30个字以内
            </div>
        </div>

        <div class="layui-form-item">
            <label for="thumbnail_img" class="layui-form-label">
                <span class="x-red">*</span>缩略图
            </label>
            <div class="layui-input-inline layui-upload" id="upload-thumbs">
                <button type="button" class="layui-btn layui-btn-primary" id="goodsImage"><i class="layui-icon"></i>上传图片</button>
                <div class="layui-upload-list">
                    {if condition = "$list.thumbnail_img  neq '' "}
                    <input name="thumbnail_img[]" value="{$list.thumbnail_img}" type="hidden">
                    <img src="{$list.thumbnail_img}" class="layui-upload-list" id="demos" width="100" height="100">
                    {else/}
                    <img class="layui-upload-list imgsc" id="demos">
                    <p id="demoTexts"></p>
                    {/if}
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <label for="focus_img" class="layui-form-label">
                <span class="x-red">*</span>焦点图
            </label>

            <button type="button" class="layui-btn layui-btn-primary" id="goodsImages"><i class="layui-icon"></i>上传图片</button>

            {if condition = "$list.focus_img >0 "}
            <div class="goods_img layui-upload-list images-block-container" id="demo">
                {volist name="$list.focus_img" id="vo"}
                <span class="image-block"><input name="focus_img[]" value="{$vo}" type="hidden">
                      <span class="del_btn"><i class="layui-icon">&#x1006;<img src="{$vo}" class="layui-upload-img" width="100" height="100"></i></span></span>
                {/volist}
            </div>
            {else /}
            <div class="goods_img layui-upload-list images-block-container" id="demo"></div>
            <p id="demoText"></p>
            {/if}
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                <span class="x-red">*</span>门店
            </label>
            <div class="layui-input-inline">
                <select style="width:8%;margin-left:15px" name="store_id">
                    {volist name="store" id="vo"}
                    <option value="{$vo.store_id}"  {if condition = "$list.store_id eq $vo.store_id"}selected="selected"{/if}>{$vo.name}</option>
                    {/volist}
                </select>
            </div>
        </div>


        <div class="layui-form-item">
            <label class="layui-form-label">
                <span class="x-red">*</span>物料分类
            </label>
            <div class="layui-input-inline">
                <select style="width:8%;margin-left:15px" lay-filter="wul" id="k" name="materiel_id">
                    {volist name="materiel" id="vo"}
                    <option value="{$vo.materiel_id}" {if condition = "$list.materiel_id_s eq $vo.materiel_id || $list.materiel_id eq $vo.materiel_id"}selected="selected"{/if}>{$vo.name}</option>
                    {/volist}
                </select>
            </div>
            <div class="layui-input-inline layui-form" id="wuliao" lay-filter="wuliao"></div>
        </div>
        <div class="layui-form-item">
            <label for="goods_deposit" class="layui-form-label">
                <span class="x-red">*</span>标签分类
            </label>
            <div class="layui-input-inline" style="width: 200px;">
                {volist name="label" id="v"}
                <dl class="role-list-form">
                    <dt><input type="checkbox" name="label[]" lay-filter="roleAuth" value="{$v['label_id']}" data-parent="0" data-level="1" lay-skin="primary" title="{$v['name']}"></dt>
                    <dd>
                        {volist name="v['names']" id="vv"}
                        <dl>
                            <dt><input type="checkbox" name="label[]" lay-filter="roleAuth" value="{$vv['label_id']}" data-pid="{$vv['parent_id']}" data-level="2" lay-skin="primary" title="{$vv['name']}"></dt>
                        </dl>
                        {/volist}
                    </dd>
                </dl>
                {/volist}
            </div>
        </div>





        <div class="layui-form-item">
            <label for="goods_deposit" class="layui-form-label">
                <span class="x-red">*</span>计价方式
            </label>
            <div class="layui-input-inline">
                <input type="radio" name="method" value="0" title="件" lay-filter="jijiafangshi" {if condition = "$list.method eq 0"} checked="checked"{/if} >
                <input type="radio" name="method" value="1" title="克重" lay-filter="jijiafangshi" {if condition = "$list.method eq 1"} checked="checked"{/if} >
            </div>
        </div>
        <div class="layui-form-item" id="huozhongzhi"></div>

        <div class="layui-form-item" id="gongfei"></div>



        <div class="layui-form-item" id="h">
            <label for="method_value" class="layui-form-label"><span class="x-red">*</span>货重值</label>
            <div class="layui-input-inline"><input type="text" id="method_value" value="{$list.method_value}" name="method_value" class="layui-input"></div>
            <div class="layui-form-mid layui-word-aux"><span class="x-red">*请填写这框的值，不填不会计算价格</span></div>
        </div>
        <div class="layui-form-item" id="g">
           <label for="cost" class="layui-form-label"><span class="x-red">*</span>工费</label>
           <div class="layui-input-inline"><input type="text" id="cost" value="{$list.cost}" name="cost" class="layui-input"></div>
            <div class="layui-form-mid layui-word-aux"><span class="x-red">*请填写这框的值，不填不会计算价格</span></div>
        </div>


        <div class="layui-form-item">
            <label for="currency" class="layui-form-label">
                <span class="x-red">*</span>货重
            </label>
            <div class="layui-input-inline">
                <input type="text" id="currency" value="{$list.currency}" name="currency" required="" lay-verify="required" autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>
            </div>
        </div>



        <div class="layui-form-item">
            <label for="goods_deposit" class="layui-form-label">
                <span class="x-red">*</span>商品方式
            </label>
            <div class="layui-input-inline layui-form" id="shangpingfangshi" lay-filter="shangpingfangshi">
                <input type="radio" name="mode" value="0" id="yikoujia" title="一口价" lay-filter="spfangshi" {if condition = "$list.mode eq 0"}  checked="checked"{/if}  >
                <input type="radio" name="mode" value="1" id="duoguige" title="多规格" lay-filter="spfangshi" {if condition = "$list.method eq 1"}  disabled="disabled"{/if} {if condition = "$list.method eq 0 and $list.mode eq 1"} checked="checked"{/if}>
            </div>
        </div>


        <div class="layui-form-item" id="shangpinguige">
            <label class="layui-form-label">选择规格类型</label>
            <div class="layui-input-inline">
                <select  lay-filter="goodstype" style="width:8%;margin-left:15px;" id="spec_type" name="type_id">
                    {volist name="goods_type" id="vo"}
                    <option value="{$vo['type_id']}" {if condition="$list['type_id'] eq $vo['type_id']" } selected="selected"{/if} >{$vo['name']}</option>
                    {/volist}
                </select>
            </div>
        </div>
        <div class="am-form-group gai_group row" id="shangpinguige2">
            <label class="gai_lable"></label>
            <div class="am-u-sm-8">
                <div style="width: 80%;padding-left: 0px;" id="ajax_spec_data" class="col-xs-8" ></div>
            </div>
        </div>

        <style>
            ul.group-list {
                width: 96%;min-width: 1000px; margin: auto 5px;list-style: disc outside none;
            }
            ul.group-list li {
                white-space: nowrap;float: left;
                width: 150px; height: 25px;
                padding: 3px 5px;list-style-type: none;
                list-style-position: outside;border: 0px;margin: 0px;
            }
            .row .table-bordered td .btn,.row .table-bordered td img{
                vertical-align: middle;
            }
            .row .table-bordered td{
                padding: 8px;
                line-height: 1.42857143;
            }
            .table-bordered{
                width: 100%
            }
            .table-bordered tr td{
                border: 1px solid #f4f4f4;
            }
            .btn-success {
                color: #fff;background-color: #449d44;border-color: #398439 solid 1px;
            }
            .btn {
                display: inline-block;
                padding: 6px 12px;
                margin-bottom: 0;
                font-size: 14px;
                font-weight: 400;
                line-height: 1.42857143;
                text-align: center;
                white-space: nowrap;
                vertical-align: middle;
                -ms-touch-action: manipulation;
                touch-action: manipulation;
                cursor: pointer;
                -webkit-user-select: none;
                -moz-user-select: none;
                -ms-user-select: none;
                user-select: none;
                background-image: none;
                border: 1px solid transparent;
                border-radius: 4px;
            }
            .col-xs-8 {
                width: 66.66666667%;
            }
            .col-xs-4 {
                width: 33.33333333%;
            }
            .col-xs-1, .col-xs-10, .col-xs-11, .col-xs-12, .col-xs-2, .col-xs-3, .col-xs-4, .col-xs-5, .col-xs-6, .col-xs-7, .col-xs-8, .col-xs-9 {
                float: left;
            }
            .row .tab-pane h4{
                padding: 10px 0;
            }
            .row .tab-pane h4 input{
                vertical-align: middle;
            }
            .table-striped>tbody>tr:nth-of-type(odd) {
                background-color: #f9f9f9;
            }
            .ncap-form-default .title{
                border-bottom: 0
            }
            .ncap-form-default dl.row, .ncap-form-all dd.opt{
                /*border-color: #F0F0F0;*/
                border: none;
            }
            .ncap-form-default dl.row:hover, .ncap-form-all dd.opt:hover{
                border: none;box-shadow: inherit;
            }
            .addprine{display: inline; }
            .alisth{margin-top: 10px}
            .p_plus strong{cursor: pointer;margin-left: 4px;}
            .freight_template {
                font-size: 14px;
                display: inline-block;
                padding: 0px 10px;
            }
        </style>


        <div class="am-form-group gai_group row" id="shangpinguige2" style="display: none">
            <label class="gai_lable"></label>
            <div class="am-u-sm-8">
                <div style="width: 80%;padding-left: 0px;" id="ajax_spec_data" class="col-xs-8" ></div>
            </div>
        </div>
        <script>

            /** 以下 商品规格相关 js*/
            $(document).ready(function(){
                // 商品模型切换时 ajax 调用  返回不同的属性输入框
                $("#spec_type").change(function(){
                    var goods_id = '{$list.goods_id}';
                    var type_id = $(this).val();
                    $.ajax({
                        type:'GET',
                        data:{goods_id:goods_id,type_id:type_id},
                        url:"{:url('Goods/ajaxGetSpecSelect')}",
                        success:function(data){
                            //console.log(data);
                            $("#ajax_spec_data").html('');
                            $("#ajax_spec_data").append(data);

                            ajaxGetSpecInput();	// 触发完  马上触发 规格输入框
                        }
                    });

                });
                // 触发商品规格
                $("#spec_type").trigger('change');

            });

            layui.use(['form'], function(){
                var form = layui.form, $ = layui.jquery;
                form.on('select(wul)', function(data){
                    $.ajax({
                        type: "POST",
                        url:  "{:url('Goods/wuliao')}",
                        data: {id:data.value},
                        success: function(res) {
                            $('#wuliao').empty();
                            $("#wuliao").append(res);
                            form.render(null, 'wuliao');

                            //租赁重新计算
                            var saletype = $("input[name=\"sale_type\"]:checked").val();
                            if(saletype==2){
                                var materiel_id = $("#materiel_id").val();
                                if(materiel_id == undefined){
                                    materiel_id = $("#k").val()
                                };

                                var cost_price = $("input[name=\"cost_price\"]").val();
                                if(cost_price==''){
                                    alert("请填写成本价")
                                };

                                //物料选择后更新结算价
                                $.ajax({
                                    type: "POST",
                                    url:  "{:url('Goods/jisuan2')}",
                                    data:{xiaoshou:$("input[name=\"price\"]").val(),cost_price:cost_price,materiel_id:materiel_id},
                                    success: function(res) {
                                        $("#settlement_price").val(res)
                                    }
                                });
                                var price = $("#price").val();

                                var wuliao_mode = $("input[name=\"mode\"]:checked").val();
                                if(price=='' || wuliao_mode==1){
                                    update();
                                }else {
                                    $.ajax({
                                        type: "POST",
                                        url:  "{:url('Goods/zulin')}",
                                        data:{materiel_id:materiel_id,price:price},
                                        success: function(res) {
                                            $('#js').empty();
                                            $("#zulingjiesuan").css("display","block");
                                            $("#js").append(res);
                                        }
                                    });
                                }
                            }else {
                                zu();
                            }
                        }
                    });

                });

                $.ajax({
                    type: "POST",
                    url:  "{:url('Goods/wuliao')}",
                    data: {id:{$list.materiel_id_s},m_id:{$list.materiel_id}},
                    success: function(res) {
                        $('#wuliao').empty();
                        $("#wuliao").append(res);
                        form.render(null, 'wuliao');
                    }
                });


                form.on('radio(jijiafangshi)', function(data){
                    if(data.value==1){
                        $.ajax({
                            type: "POST",
                            url:  "{:url('Goods/kuzhongzi')}",
                            success: function(res) {
                                $('#huozhongzhi').empty();
                                $("#huozhongzhi").append(res);
                            }
                        });
                        $.ajax({
                            type: "POST",
                            url:  "{:url('Goods/gongfei')}",
                            success: function(res) {
                                $('#gongfei').empty();
                                $("#gongfei").append(res);
                            }
                        });
                        $("#duoguige").attr("disabled",null);
                        //$("#yikoujia").attr("checked",true);
                        $("#duoguige").attr("disabled",true);
                        form.render('radio', 'shangpingfangshi');
                        $("#shangpinguige").css("display","none");
                        $("#shangpinguige2").css("display","none");

                    }else {
                        $('#gongfei').empty();
                        $('#huozhongzhi').empty();
                        $("#duoguige").attr("disabled",null);
                        $("#yikoujia").attr("checked",null);
                        $("#h").css("display","none");
                        $("#g").css("display","none");
                        form.render('radio', 'shangpingfangshi');
                    }
                });



                form.on('radio(spfangshi)', function(data){
                    if(data.value==1){
                        $("#yikou").css("display","none");
                        $("#shangpinguige").css("display","block");
                        $("#shangpinguige2").css("display","block");
                        $("#price").val('');
                        $("#zulingjiesuan").css("display","none");

                        $("#yes").attr("checked",null);
                        $("#no").attr("checked",true);
                        form.render('radio','shifouzulin');
                        $('#js').empty();
                    }else {
                        $("#shangpinguige").css("display","none");
                        $("#shangpinguige2").css("display","none");
                        $("#yikou").css("display","block");
                        $('#js').empty();
                        $("#yes").attr("checked",null);
                        $("#no").attr("checked",true);
                        form.render('radio','shifouzulin');

                    }
                });



                form.on('select(selectwuliao)', function(data){
                    $.ajax({
                        type: "POST",
                        url:  "{:url('Goods/jisuan')}",
                        data: {id:data.value},
                        success: function(res) {
                            // $('#wuliao').empty();
                            // $("#wuliao").append(res);
                            // form.render(null, 'wuliao');
                        }
                    });

                    //租赁重新计算
                    var saletype = $("input[name=\"sale_type\"]:checked").val();
                    if(saletype==2){
                        var materiel_id = data.value;;
                        var price = $("#price").val();
                        var wuliao_mode = $("input[name=\"mode\"]:checked").val();
                        if(price=='' || wuliao_mode==1){
                            heavy();
                        }else {
                            $.ajax({
                                type: "POST",
                                url:  "{:url('Goods/zulin')}",
                                data:{materiel_id:materiel_id,price:price},
                                success: function(res) {
                                    $('#js').empty();
                                    $("#zulingjiesuan").css("display","block");
                                    $("#js").append(res);
                                }
                            });
                        }
                    }else {
                        zu();
                    }
                });





                $(document).ready(function(){
                    // 商品模型切换时 ajax 调用  返回不同的属性输入框
                    form.on('select(goodstype)', function(data){
                        var goods_id = '{$list.goods_id}';
                        var type_id = data.value;
                        $.ajax({
                            type:'GET',
                            data:{goods_id:goods_id,type_id:type_id},
                            url:"{:url('Goods/ajaxGetSpecSelect')}",
                            success:function(data){
                                $("#ajax_spec_data").html('')
                                $("#ajax_spec_data").append(data);
                                ajaxGetSpecInput();	// 触发完  马上触发 规格输入框
                            }
                        });
                    });
                    // 触发商品规格
                    $("#spec_type").trigger('change');

                });

            });


            $(function(){
                //货重值
                $("body").on("keyup","input[name=\"method_value\"]",function(){
                    var method_value = $(this).val();
                    if(method_value==''){
                        alert("请填写货重值")
                    }
                    $("input[name=\"method_value\"]").val(method_value);
                    $.ajax({
                        type: "POST",
                        url:  "{:url('Goods/jisuan')}",
                        data:{kz:method_value,gf:$("input[name=\"cost\"]").val()},
                        success: function(res) {
                            $("#price").val(res);

                            //租赁重新计算
                            var saletype = $("input[name=\"sale_type\"]:checked").val();
                            if(saletype==2){
                                var materiel_id = $("#materiel_id").val();
                                if(materiel_id == undefined){
                                    materiel_id = $("#k").val()
                                }
                                var price = $("#price").val();
                                var wuliao_mode = $("input[name=\"mode\"]:checked").val();
                                if(price=='' || wuliao_mode==1){
                                    heavy();
                                }else {
                                    $.ajax({
                                        type: "POST",
                                        url:  "{:url('Goods/zulin')}",
                                        data:{materiel_id:materiel_id,price:price},
                                        success: function(res) {
                                            $('#js').empty();
                                            $("#zulingjiesuan").css("display","block");
                                            $("#js").append(res);
                                        }
                                    });
                                }
                            }else {
                                zu();
                            }
                        }
                    });
                });

                //工费
                $("body").on("keyup","input[name=\"cost\"]",function(){
                    var cost = $(this).val();
                    if(cost==''){
                        alert("请填写工费值")
                    }
                    $("input[name=\"cost\"]").val(cost);
                    $.ajax({
                        type: "POST",
                        url:  "{:url('Goods/jisuan')}",
                        data:{gf:cost,kz:$("input[name=\"method_value\"]").val()},
                        success: function(res) {
                            $("#price").val(res);

                            //租赁重新计算
                            var saletype = $("input[name=\"sale_type\"]:checked").val();
                            if(saletype==2){
                                var materiel_id = $("#materiel_id").val();
                                if(materiel_id == undefined){
                                    materiel_id = $("#k").val()
                                }
                                var price = $("#price").val();
                                var wuliao_mode = $("input[name=\"mode\"]:checked").val();
                                if(price=='' || wuliao_mode==1){
                                    heavy();
                                }else {
                                    $.ajax({
                                        type: "POST",
                                        url:  "{:url('Goods/zulin')}",
                                        data:{materiel_id:materiel_id,price:price},
                                        success: function(res) {
                                            $('#js').empty();
                                            $("#zulingjiesuan").css("display","block");
                                            $("#js").append(res);
                                        }
                                    });
                                }
                            }else {
                                zu();
                            }
                        }
                    });

                });


                //成本价
                $("body").on("keyup","input[name=\"cost_price\"]",function(){
                    var cost_price = $(this).val();
                    if(cost_price==''){
                        alert("请填写成本价")
                    }
                    var materiel_id = $("#materiel_id").val();

                    if(materiel_id == undefined){
                        materiel_id = $("#k").val()
                    }
                    $.ajax({
                        type: "POST",
                        url:  "{:url('Goods/jisuan2')}",
                        data:{xiaoshou:$("input[name=\"price\"]").val(),cost_price:cost_price,materiel_id:materiel_id},
                        success: function(res) {
                            $("#settlement_price").val(res);

                            //租赁重新计算
                            var saletype = $("input[name=\"sale_type\"]:checked").val();
                            if(saletype==2){
                                var materiel_id = $("#materiel_id").val();
                                if(materiel_id == undefined){
                                    materiel_id = $("#k").val()
                                }
                                var price = $("#price").val();
                                var wuliao_mode = $("input[name=\"mode\"]:checked").val();
                                if(price=='' || wuliao_mode==1){
                                    heavy();
                                }else {
                                    $.ajax({
                                        type: "POST",
                                        url:  "{:url('Goods/zulin')}",
                                        data:{materiel_id:materiel_id,price:price},
                                        success: function(res) {
                                            $('#js').empty();
                                            $("#zulingjiesuan").css("display","block");
                                            $("#js").append(res);
                                        }
                                    });
                                }
                            }else {
                                zu();
                            }
                        }
                    });

                });

            })


            var formData = {:json_encode($goods_lable)};
            layui.use(['form'], function() {
                var $ = layui.jquery, form = layui.form;
                /* 有BUG 待完善*/
                form.on('checkbox(roleAuth)', function(data) {

                    var child = $(data.elem).parent('dt').siblings('dd').find('input');
                    /* 自动选中父节点 */
                    var check_parent = function (label_id) {
                        var self = $('.role-list-form input[value="'+label_id+'"]');
                        var pid = self.attr('data-pid') || '';
                        self.prop('checked', true);
                        if (pid == '') {
                            return false;
                        }
                        check_parent(pid);
                    };
                    /* 自动选中子节点 */
                    child.each(function(index, item) {
                        item.checked = data.elem.checked;
                    });
                    check_parent($(data.elem).attr('data-pid'));
                    form.render('checkbox');
                });

                /* 权限赋值 */
                if (formData) {
                    for(var i in formData) {
                        $('.role-list-form input[value="'+formData[i]['label_id']+'"]').prop('checked', true);
                    }
                    form.render('checkbox');
                }
            });

        </script>
        <div class="layui-form-item" id="yikou" style="display: none">
            <label for="detection" class="layui-form-label">
            </label>
            <div class="layui-input-inline">
                <table class="table table-bordered">
                    <tr>
                        <td>销售价</td>
                        <td>成本价(成本价输入后结算价才会计算)</td>
                        <td>结算价</td>
                        <td>市场价</td>
                        <td>库存</td>
                        <td>激活码(英文下的逗号进行分割)</td>
                    </tr>
                    <tr>
                        <td><input type="number" min="1" id="price" name="price" value="{$spec_goods_price.price}" /></td>
                        <td><input type="number" min="1" name="cost_price"  value="{$spec_goods_price.cost_price}"/></td>
                        <td><input type="number" min="1" id="settlement_price" name="settlement_price"  value="{$spec_goods_price.settlement_price}"/></td>
                        <td><input type="number" min="1" id="market_price" name="market_price" value="{$spec_goods_price.market_price}" /></td>
                        <td><input type="number" min="1" name="store" value="{$spec_goods_price.store}"/></td>
                        <td><input type="text" name="barcodes" style="width: 400px;" value="{$spec_goods_price.barcodes}"/></td>
                    </tr>
                </table>
            </div>
        </div>


        <div class="layui-form-item">
            <label for="goods_deposit" class="layui-form-label">
                <span class="x-red">*</span>是否租赁
            </label>
            <div class="layui-input-inline layui-form" id="sfzl" lay-filter="shifouzulin">
                <input type="radio" name="sale_type" id="yes" lay-filter="zulin" value="2" {if condition = "$list.sale_type eq 2"} checked="checked"{/if} title="是">
                <input type="radio" name="sale_type" id="no"  lay-filter="zulin" value="1" {if condition = "$list.sale_type eq 1"} checked="checked"{/if} title="不是">
            </div>
        </div>


        <div class="layui-form-item" id="zulingjiesuan" style="display: none">
            <label for="detection" class="layui-form-label"></label>
            <div class="layui-input-inline" id="js">
                {if condition = "$list.sale_type eq 2"}
                {volist name="lease" id="vo"}
                <table class="table table-bordered" id="{$vo['price_key']}">
                    {if condition = "$vo.price_key neq 0"}
                    <tr><td style="border: 0;">{$vo.price_key_name}</td></tr>
                    {/if}
                    <tr><td>押金</td><td>租金</td><td>商家结算</td></tr>
                    {if condition = "$vo.price_key eq 0"}
                    <tr>
                        <td><input type="number" name="deposit" value="{$vo.deposit}" /></td>
                        <td><input type="number" name="rent"  value="{$vo.rent}"/></td>
                        <td><input type="number" name="settlement"  value="{$vo.settlement}"/></td>
                    </tr>
                    {else /}

                    <tr>
                        <td><input type="number" name="item[{$vo['price_key']}][deposit]" value="{$vo['deposit']}"/></td>
                        <td><input type="number" name="item[{$vo['price_key']}][rent]" value="{$vo['rent']}"/></td>
                        <td><input type="number" name="item[{$vo['price_key']}][settlement]" value="{$vo['settlement']}"/></td>
                    </tr>
                    {/if}
                </table>
                {/volist}
                {/if}
            </div>
        </div>

        <script>
            layui.use(['form'], function() {
                var $ = layui.jquery, form = layui.form;
                form.render('radio');
                form.on('radio(zulin)', function(data){
                    if(data.value==2){
                        var materiel_id = $("#materiel_id").val();
                        if(materiel_id == undefined){
                            materiel_id = $("#k").val()
                        }
                        var price = $("#price").val();
                        var wuliao_mode = $("input[name=\"mode\"]:checked").val();
                        if(price=='' || wuliao_mode==1){
                            $("#goods_spec_table1  button").each(function(){
                                if($(this).hasClass('btn-success'))
                                {
                                    price =$("input[name='item["+$(this).data('item_id')+"][price]']").val();
                                    $.ajax({
                                        type: "POST",
                                        url:  "{:url('Goods/zulin')}",
                                        data:{materiel_id:materiel_id,price:price,item:$(this).data('item_id')},
                                        success: function(res) {
                                            //$('#js').empty();
                                            $("#zulingjiesuan").css("display","block");
                                            $("#js").append(res);
                                        }
                                    });
                                }
                            });
                        }else {
                            $.ajax({
                                type: "POST",
                                url:  "{:url('Goods/zulin')}",
                                data:{materiel_id:materiel_id,price:price},
                                success: function(res) {
                                    $('#js').empty();
                                    $("#zulingjiesuan").css("display","block");
                                    $("#js").append(res);
                                }
                            });
                        }
                    }else {
                        zu();
                    }
                });


                var sale_type = {$list['sale_type']};
                if(sale_type==2){
                    $("#zulingjiesuan").css("display","block");
                }




                $(function(){
                    //改变销售价后
                    $("body").on("keyup","input[name=\"price\"]",function(){
                        var saletype = $("input[name=\"sale_type\"]:checked").val();
                        if(saletype==2){
                            var materiel_id = $("#materiel_id").val();
                            if(materiel_id == undefined){
                                materiel_id = $("#k").val()
                            }
                            var price = $("#price").val();
                            var wuliao_mode = $("input[name=\"mode\"]:checked").val();
                            if(price=='' || wuliao_mode==1){
                                heavy();
                            }else {
                                $.ajax({
                                    type: "POST",
                                    url:  "{:url('Goods/zulin')}",
                                    data:{materiel_id:materiel_id,price:price},
                                    success: function(res) {
                                        $('#js').empty();
                                        $("#zulingjiesuan").css("display","block");
                                        $("#js").append(res);
                                    }
                                });
                            }
                        }else {
                            zu();
                        }
                    });



                    //货重
                    // $("body").on("keyup","input[name=\"method_value\"]",function(){
                    //     var saletype = $("input[name=\"sale_type\"]").val();
                    //     if(saletype==2){
                    //         var materiel_id = $("#materiel_id").val();
                    //         if(materiel_id == undefined){
                    //             materiel_id = $("#k").val()
                    //         }
                    //         var price = $("#price").val();
                    //         if(price==''){
                    //             heavy();
                    //         }else {
                    //             $.ajax({
                    //                 type: "POST",
                    //                 url:  "{:url('Goods/zulin')}",
                    //                 data:{materiel_id:materiel_id,price:price},
                    //                 success: function(res) {
                    //                     $('#js').empty();
                    //                     $("#zulingjiesuan").css("display","block");
                    //                     $("#js").append(res);
                    //                 }
                    //             });
                    //         }
                    //     }else {
                    //         zu();
                    //     }
                    // });

                    //工费
                    // $("body").on("keyup","input[name=\"cost\"]",function(){
                    //     var saletype = $("input[name=\"sale_type\"]").val();
                    //     if(saletype==2){
                    //         var materiel_id = $("#materiel_id").val();
                    //         if(materiel_id == undefined){
                    //             materiel_id = $("#k").val()
                    //         }
                    //         var price = $("#price").val();
                    //
                    //         if(price==''){
                    //             heavy();
                    //         }else {
                    //             $.ajax({
                    //                 type: "POST",
                    //                 url:  "{:url('Goods/zulin')}",
                    //                 data:{materiel_id:materiel_id,price:price},
                    //                 success: function(res) {
                    //                     $('#js').empty();
                    //                     $("#zulingjiesuan").css("display","block");
                    //                     $("#js").append(res);
                    //                 }
                    //             });
                    //         }
                    //     }else {
                    //         zu();
                    //     }
                    //
                    // });

                })

            });


            var yk = {$list['mode']};
            var fangshi = {$list['method']}

            if(fangshi==1){
                $("#h").css("display","block");
                $("#g").css("display","block");
                $("#yikou").css("display","block");
                $("#shangpinguige").css("display","none");
                $("#shangpinguige2").css("display","none");
            }else {
                if(yk==0){
                    // $("#h").css("display","block");
                    // $("#g").css("display","block");
                    $("#h").css("display","none");
                    $("#g").css("display","none");
                    $("#yikou").css("display","block");
                    $("#shangpinguige").css("display","none");
                    $("#shangpinguige2").css("display","none");
                }else {
                    $("#h").css("display","none");
                    $("#g").css("display","none");
                    $("#yikou").css("display","none");
                    $("#shangpinguige").css("display","block");
                    $("#shangpinguige2").css("display","block");
                }
            }


            function heavy(){
                var materiel_id = $("#materiel_id").val();
                if(materiel_id == undefined){
                    materiel_id = $("#k").val()
                }
                var saletype = $("input[name=\"sale_type\"]:checked").val();
                if(saletype==2){
                    $("#goods_spec_table1  button").each(function(){
                        if($(this).hasClass('btn-success'))
                        {
                            if($("input[name='item["+$(this).data('item_id')+"][deposit]']").length>0){
                                   // $("#"+$(this).data('item_id')+"").remove();
                                }else {
                                    price = $("input[name='item["+$(this).data('item_id')+"][price]']").val();
                                    $.ajax({
                                        type: "POST",
                                        url:  "{:url('Goods/zulin')}",
                                        data:{materiel_id:materiel_id,price:price,item:$(this).data('item_id')},
                                        success: function(res) {
                                            //$('#js').empty();
                                            $("#zulingjiesuan").css("display","block");
                                            $("#js").append(res);
                                        }
                                    });
                                }
                        }else if($(this).hasClass('btn-default')){
                            if($("input[name='item["+$(this).data('item_id')+"][deposit]']").length>0){
                                $("#"+$(this).data('item_id')+"").remove();
                            }
                        }
                    });
                };
            }


            //选择物料后，进行更新操作
            function update(){
                var materiel_id = $("#materiel_id").val();
                if(materiel_id == undefined){
                    materiel_id = $("#k").val()
                }
                var saletype = $("input[name=\"sale_type\"]:checked").val();
                if(saletype==2){
                    $("#goods_spec_table1  button").each(function(){
                        if($(this).hasClass('btn-success'))
                        {
                            $("#"+$(this).data('item_id')+"").remove();
                                price = $("input[name='item["+$(this).data('item_id')+"][price]']").val();
                                $.ajax({
                                    type: "POST",
                                    url:  "{:url('Goods/zulin')}",
                                    data:{materiel_id:materiel_id,price:price,item:$(this).data('item_id')},
                                    success: function(res) {
                                        //$('#js').empty();
                                        $("#zulingjiesuan").css("display","block");
                                        $("#js").append(res);
                                    }
                                });

                        }
                    });
                };
            }

            function zu(){
                $("#zulingjiesuan").css("display","none");
                $('#js').empty();
            }

            //规格值发生变化时
            $(function () {
                $(document).on("input propertychange","#ge",function(){
                    var materiel_id = $("#materiel_id").val();
                    if(materiel_id == undefined){
                        materiel_id = $("#k").val()
                    }

                    var saletype = $("input[name=\"sale_type\"]:checked").val();
                    if(saletype==2){
                        price = $(this).val();
                        var s = parseInt($(this).attr("name").replace(/[^0-9]/ig,""));
                        $("#"+s).remove();
                        $.ajax({
                            type: "POST",
                            url:  "{:url('Goods/zulin')}",
                            data:{materiel_id:materiel_id,price:price,item:s},
                            success: function(res) {
                                $("#zulingjiesuan").css("display","block");
                                $("#js").append(res);
                            }
                        });
                    };

                });
            })



        </script>
        <div class="layui-form-item">
            <label for="detection" class="layui-form-label">
                <span class="x-red"></span>检查机构
            </label>
            <div class="layui-input-inline">
                <input type="text" id="detection" value="{$list.detection}" name="detection" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="money" class="layui-form-label">
                <span class="x-red"></span>款号
            </label>
            <div class="layui-input-inline">
                <input type="text" id="money" value="{$list.money}" name="money" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="material" class="layui-form-label">
                <span class="x-red"></span>材质
            </label>
            <div class="layui-input-inline">
                <input type="text" id="material" value="{$list.material}" name="material" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="stone" class="layui-form-label">
                <span class="x-red"></span>石料
            </label>
            <div class="layui-input-inline">
                <input type="text" id="stone" value="{$list.stone}" name="stone" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="food" class="layui-form-label">
                <span class="x-red"></span>品名
            </label>
            <div class="layui-input-inline">
                <input type="text" id="food" value="{$list.food}" name="food" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="inch" class="layui-form-label">
                <span class="x-red"></span>手寸
            </label>
            <div class="layui-input-inline">
                <input type="text" id="inch" value="{$list.inch}" name="inch" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="weight" class="layui-form-label">
                <span class="x-red"></span>净金重
            </label>
            <div class="layui-input-inline">
                <input type="text" id="weight" value="{$list.weight}" name="weight" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="stone_number" class="layui-form-label">
                <span class="x-red"></span>主石号
            </label>
            <div class="layui-input-inline">
                <input type="text" id="stone_number" value="{$list.stone_number}" name="stone_number" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="stone_type" class="layui-form-label">
                <span class="x-red"></span>主石类型
            </label>
            <div class="layui-input-inline">
                <input type="text" id="stone_type" value="{$list.stone_type}" name="stone_type" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="stone_shape" class="layui-form-label">
                <span class="x-red"></span>主石形状
            </label>
            <div class="layui-input-inline">
                <input type="text" id="stone_shape" value="{$list.stone_shape}" name="stone_shape" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="cleanliness" class="layui-form-label">
                <span class="x-red"></span>净度
            </label>
            <div class="layui-input-inline">
                <input type="text" id="cleanliness" value="{$list.cleanliness}" name="cleanliness" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="color" class="layui-form-label">
                <span class="x-red"></span>颜色
            </label>
            <div class="layui-input-inline">
                <input type="text" id="color" value="{$list.color}" name="color" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="stone_weight" class="layui-form-label">
                <span class="x-red"></span>主石重
            </label>
            <div class="layui-input-inline">
                <input type="text" id="stone_weight" value="{$list.stone_weight}" name="stone_weight" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="main_stones" class="layui-form-label">
                <span class="x-red"></span>主石数
            </label>
            <div class="layui-input-inline">
                <input type="text" id="main_stones" value="{$list.main_stones}" name="main_stones" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="goods_stone_shape" class="layui-form-label">
                <span class="x-red"></span>辅石形状
            </label>
            <div class="layui-input-inline">
                <input type="text" id="goods_stone_shape" value="{$list.goods_stone_shape}" name="goods_stone_shape" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="auxiliary_stone_weight" class="layui-form-label">
                <span class="x-red"></span>辅石重
            </label>
            <div class="layui-input-inline">
                <input type="text" id="auxiliary_stone_weight" value="{$list.auxiliary_stone_weight}" name="auxiliary_stone_weight" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="number_of_auxiliary_stones" class="layui-form-label">
                <span class="x-red"></span>辅石数
            </label>
            <div class="layui-input-inline">
                <input type="text" id="number_of_auxiliary_stones" value="{$list.number_of_auxiliary_stones}" name="number_of_auxiliary_stones" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="number_of_auxiliary_stones" class="layui-form-label">
                <span class="x-red"></span>辅石数
            </label>
            <div class="layui-input-inline">
                <input type="text" id="number_of_auxiliary_stones" value="{$list.number_of_auxiliary_stones}" name="number_of_auxiliary_stones" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">
                <span class="x-red">*</span>会员折扣
            </label>
            <div class="layui-input-block">
                <input type="radio" name="discount" value="1" title="是" {if condition = "$list.discount eq 1"} checked="checked"{/if} ">
                <input type="radio" name="discount" value="0" title="否" {if condition = "$list.discount eq 0"} checked="checked"{/if} >
            </div>
        </div>



        <div class="layui-form-item">
            <label class="layui-form-label">
                <span class="x-red">*</span>发货方式
            </label>
            <div class="layui-input-block">
                <input type="checkbox" name="delivery[]" lay-skin="primary" title="快递" value="1" {if condition = "$list.delivery eq 1"} checked="checked" {elseif condition="$list.delivery eq 0"/}checked="checked"{/if}>
                <input type="checkbox" name="delivery[]" lay-skin="primary" title="自提" value="2" {if condition = "$list.delivery eq 2"} checked="checked" {elseif condition="$list.delivery eq 0"/}checked="checked" {/if}>
            </div>
        </div>
        <div class="layui-form-item">
            <label for="details" class="layui-form-label">
                <span class="x-red"></span>描述
            </label>
            <div class="layui-input-inline" style="width: 86%;">
                <textarea id="details"  name="details">{$list.details}</textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <label for="L_repass" class="layui-form-label"></label>
            <button  class="layui-btn" lay-filter="formSubmits" lay-submit="">提交</button>
        </div>
    </form>
</div>
<style>
    #LAY_layedit_1 {height: 500px !important;}
</style>
<script>
    layui.use(['layedit','form'], function(){
        var layedit = layui.layedit;
        var form = layui.form;
        form.render();
        layedit.set({
            uploadImage: {
                url:"{:url('Upload/uploadFiles')}"//接口url
                ,type: 'post' //默认post
            }
        });
        var details =  layedit.build('details'); //建立编辑器
        form.on('submit(formSubmits)', function(data) {
            var _form = '';
            if ($(this).attr('data-form')) {
                _form = $($(this).attr('data-form'));
            } else {
                _form = $(this).parents('form');
            }
            layedit.sync(details)
            $('#details').val(base64.encode($('#details').val()));
            layer.msg('数据提交中...',{time:500000});
            $.ajax({
                type: "POST",
                url: _form.attr('action'),
                data: _form.serialize(),
                success: function(res) {
                    if(res.code == 200) {
                        layer.alert(res.msg, {icon: 6},function () {
                            // 获得frame索引
                            var index = parent.layer.getFrameIndex(window.name);
                            //关闭当前frame
                            parent.layer.close(index);
                            parent.location.reload();
                        })
                    } else {
                        layer.msg(res.msg,{icon: 2});
                    }
                }
            });
            return false;
        });
    });
</script>

{include file="public/footer" /}